<?php

namespace App\Providers;

use Illuminate\Support\Facades\Gate;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Laravel\Passport\Passport;

class AuthServiceProvider extends ServiceProvider
{
    /**
     * The policy mappings for the application.
     *
     * @var array
     */
    protected $policies = [
        'App\Model' => 'App\Policies\ModelPolicy',
    ];

    /**
     * Register any authentication / authorization services.
     *
     * @return void
     */
    public function boot()
    {
        $this->registerPolicies();

        //这个函数会注册发出访问令牌并撤销访问令牌、客户端和个人访问令牌所必需的路由：
        Passport::routes();

        //令牌的有效期
        //默认情况下，Passport 发放的访问令牌是有一年有效期的，不需要刷新。但是如果你想自定义访问令牌的有效期，可以使用 tokensExpireIn 和 refreshTokensExpireIn 方法。
        Passport::tokensExpireIn(now()->addDays(15));
        Passport::refreshTokensExpireIn(now()->addDays(30));

        //开启隐式授权令牌
        //Passport::enableImplicitGrant();
    }
}
